home *** CD-ROM | disk | FTP | other *** search
/ Risc World 3 / Risc World 3.iso / SOFTWARE / ISSUE6 / PD / PDF / GuiLib / Wimp / c++ / GuiWimpMessage < prev   
Text File  |  2003-02-14  |  4KB  |  109 lines

  1. //--------------------------------------------------------------------------
  2. //
  3. //   Copyright (c) 2002, Colin Granville
  4. //
  5. //   All rights reserved.
  6. //
  7. //   Redistribution and use in source and binary forms, with or
  8. //   without modification, are permitted provided that the following 
  9. //   conditions are met:
  10. //
  11. //      * Redistributions of source code must retain the above copyright 
  12. //        notice, this list of conditions and the following disclaimer.
  13. //
  14. //      * Redistributions in binary form must reproduce the above 
  15. //        copyright notice, this list of conditions and the following 
  16. //        disclaimer in the documentation and/or other materials 
  17. //        provided with the distribution.
  18. //
  19. //      * The name Colin Granville may not be used to endorse or promote 
  20. //        products derived from this software without specific prior 
  21. //        written permission.
  22. //
  23. //   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
  24. //   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
  25. //   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
  26. //   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
  27. //   COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
  28. //   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
  29. //   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
  30. //   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
  31. //   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
  32. //   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  33. //   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
  34. //   OF THE POSSIBILITY OF SUCH DAMAGE.
  35. //
  36. //--------------------------------------------------------------------------
  37.  
  38. #include "GuiWimp.h"
  39. #include "GuiWimpMessage.h"
  40.  
  41. int GuiWimpMessageBase::send(int mess_code,int window_or_dest_task_handle,int icon_handle)
  42. {
  43.   hdr.yourRef=0;
  44.   hdr.actionCode=mess_code;
  45.   _swix(Wimp_SendMessage,_INR(0,3), GuiWimp_EUserMessage,this,
  46.                                     window_or_dest_task_handle,icon_handle);
  47.   return hdr.myRef;
  48. }
  49.  
  50. //*************************************************************************
  51.        
  52. int GuiWimpMessageBase::sendRecorded(int mess_code,
  53.                                   int window_or_dest_task_handle,int icon_handle)
  54. {
  55.   hdr.yourRef=0;
  56.   hdr.actionCode=mess_code;
  57.   _swix(Wimp_SendMessage,_INR(0,3), GuiWimp_EUserMessageRecorded,this,
  58.                                     window_or_dest_task_handle,icon_handle);
  59.   return hdr.myRef;
  60. }
  61.  
  62. //*************************************************************************
  63.        
  64. int GuiWimpMessageBase::reply(int mess_code)
  65. {
  66.   hdr.yourRef=hdr.myRef;
  67.   hdr.actionCode=mess_code;
  68.   _swix(Wimp_SendMessage,_INR(0,2),GuiWimp_EUserMessage,this,hdr.sender);
  69.   return hdr.myRef;
  70. }
  71.  
  72. //*************************************************************************
  73.  
  74. int GuiWimpMessageBase::replyRecorded(int mess_code)
  75. {
  76.   hdr.yourRef=hdr.myRef;
  77.   hdr.actionCode=mess_code;
  78.   _swix(Wimp_SendMessage,_INR(0,2),GuiWimp_EUserMessageRecorded,this,hdr.sender);
  79.   return hdr.myRef;
  80. }
  81.  
  82. //*************************************************************************
  83.  
  84. int GuiWimpMessageBase::acknowledge()
  85. {
  86.   hdr.yourRef=hdr.myRef;
  87.   _swix(Wimp_SendMessage,_INR(0,2),GuiWimp_EUserMessageAcknowledge,this,hdr.sender);
  88.   return hdr.myRef;
  89. }
  90.  
  91. //*************************************************************************
  92.  
  93. char* GuiWimpMessageBase::copyString(char* to,const char* from)
  94. {
  95.   char* begin=(char*)this;
  96.   if (begin>to ||to-begin>=GuiWimpMessage::MAX_SIZE) return 0;
  97.   char* end=begin+GuiWimpMessage::MAX_SIZE-1;
  98.   for (;to<end;to++)
  99.   {
  100.     if (*from==0) break;
  101.     *to=*from++;
  102.   }
  103.   hdr.size=((to-begin+4)&~3);
  104.   *to=0;
  105.   return to;
  106. }
  107.  
  108.  
  109.